<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>

    <h:form id="professor" styleClass="edit">
    
        <rich:panel>
            <f:facet name="header">#{professorHome.managed ? messages['application.label.edit'] : messages['application.label.add']} #{messages['application.professor.label']}</f:facet>

            <s:decorate id="numRmDecoration" template="layout/edit.xhtml">
                <ui:define name="label">#{messages['application.professor.label.rm']}</ui:define>
                <h:inputText id="numRm" 
                       required="true"
                           size="6"
                      maxlength="6"
                          value="#{professorHome.instance.numRm}">
                    <a:support event="onblur" reRender="numRmDecoration" bypassUpdates="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="nomProfessorDecoration" template="layout/edit.xhtml">
                <ui:define name="label">#{messages['application.professor.label.nome']}</ui:define>
                <h:inputText id="nomProfessor" 
                       required="true"
                           size="50"
                      maxlength="50"
                          value="#{professorHome.instance.nomProfessor}">
                    <a:support event="onblur" reRender="nomProfessorDecoration" bypassUpdates="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="numEnderecoDecoration" template="layout/edit.xhtml">
                <ui:define name="label">#{messages['application.endereco.label.numero']}</ui:define>
                <h:inputText id="numEndereco"
                       required="true"
                          value="#{professorHome.instance.numEndereco}">
                    <a:support event="onblur" reRender="numEnderecoDecoration" bypassUpdates="true"/>
                </h:inputText>
            </s:decorate>

            <s:decorate id="desComplementoDecoration" template="layout/edit.xhtml">
                <ui:define name="label">#{messages['application.endereco.label.complemento']}</ui:define>
                <h:inputText id="desComplemento" 
                           size="20"
                      maxlength="20"
                          value="#{professorHome.instance.desComplemento}">
                    <a:support event="onblur" reRender="desComplementoDecoration" bypassUpdates="true"/>
                </h:inputText>
            </s:decorate>
        
            <div style="clear:both">
                <span class="required">*</span> 
                #{messages['application.label.requiredfiels']}
            </div>
            
        </rich:panel>
                
        <div class="actionButtons">

            <h:commandButton id="save" 
                          value="#{messages['application.label.saveCreate']}" 
                         action="#{professorHome.persist}"
                       disabled="#{!professorHome.wired}"
                       rendered="#{!professorHome.managed}"/>  
                          			  
            <h:commandButton id="update" 
                          value="#{messages['application.label.saveUpdate']}" 
                         action="#{professorHome.update}"
                       rendered="#{professorHome.managed}"/>
                        			  
            <h:commandButton id="delete" 
                          value="#{messages['application.label.delete']}" 
                         action="#{professorHome.remove}"
                       rendered="#{professorHome.managed}"/>
                    
            <s:button id="done" 
                   value="#{messages['application.label.done']}"
             propagation="end"
                    view="/Professor.xhtml"
                rendered="#{professorHome.managed}"/>
                
            <s:button id="cancel" 
                   value="#{messages['application.label.cancel']}"
             propagation="end"
                    view="/#{empty professorFrom ? 'ProfessorList' : professorFrom}.xhtml"
                rendered="#{!professorHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">
    
    <rich:tab label="#{messages['application.professor.label.professorendereco']} *" labelClass="required">
    <div class="association" id="enderecoParent">
    
        <h:outputText value="#{messages['application.professor.label.professorendereco.empty']}" 
                   rendered="#{professorHome.instance.endereco == null}"/>
        
        <rich:dataTable var="endereco" 
                   value="#{professorHome.instance.endereco}" 
                rendered="#{professorHome.instance.endereco != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="enderecoTable">
            <h:column>
                <f:facet name="header">#{messages['application.endereco.label.cep']}</f:facet>
                #{endereco.idtCep}
            </h:column>
            <h:column>
                <f:facet name="header">#{messages['application.endereco.label.logradouro']}</f:facet>
                #{endereco.desLogradouro}
            </h:column>
            <h:column>
                <f:facet name="header">#{messages['application.endereco.label.bairro']}</f:facet>
                #{endereco.desBairro}
            </h:column>
            <h:column>
                <f:facet name="header">#{messages['application.endereco.label.cidade']}</f:facet>
                #{endereco.desCidade}
            </h:column>
            <h:column>
                <f:facet name="header">#{messages['application.endereco.label.uf']}</f:facet>
                #{endereco.desUf}
            </h:column>
            <h:column>
                <f:facet name="header">#{messages['application.label.select']}</f:facet>
                <s:link view="/Endereco.xhtml" 
                         id="viewendereco" 
                      value="#{messages['application.label.view']}" 
                propagation="none">
                    <f:param name="enderecoIdtCep" 
                           value="#{endereco.idtCep}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{messages['application.label.select']}"
                       view="/EnderecoList.xhtml">
                <f:param name="from" value="ProfessorEdit"/>
            </s:button>
        </div>
        
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
